package com.lagou.order.service.impl;

import com.lagou.common.pojo.Goods;
import com.lagou.common.pojo.Order;
import com.lagou.order.mapper.OrderMapper;
import com.lagou.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Override
    public Order geOrderById(String id) {
        Order order = orderMapper.getOrderById(id);
        System.out.println("order = " + order);
        return order;
    }

    @Override
    public Map<List<Order>, Integer> getAllOrder(String timeB, String timeE, Integer status, Integer pageIndex, Integer pageSize) {
        Integer offset = (pageIndex-1)*pageSize;
        List<Order> orderList = orderMapper.getAllOrder(timeB, timeE, status, offset, pageSize);
        Integer countOfOrder = orderMapper.getCountOfOrder(timeB, timeE, status);
        Map<List<Order>, Integer> map = new HashMap<>();
        map.put(orderList, countOfOrder);
        return map;
    }

    @Override
    public Integer getGoodsByOrderId(String id) {
        return orderMapper.getGoodsByOrderId(id);
    }
}
